function registerAndLogin(btn,path,msg,href) {
    btn.addEventListener("click",async function(){
      let form= document.querySelector('form');
      let data= serialize(form,{hash:true})
      // console.log(data.username.length)
      if(!data.username||data.username.length<2) return tip("请输入账号")
      if(!data.password||data.password.length<6) return tip("请输入密码")
      try {
     let {data:{token,username}}= await axios.post(path,data)
    if(msg=="登录"){
        localStorage.setItem("username",username)
        localStorage.setItem("token",token)
    }
        tip(msg+"成功")
        setTimeout(function(){
          location.href=href
        },1500)
      } catch (error) {
         console.dir(error.response)
         if(error.response.status==409||error.response.status==400)return tip(error.response.data.message)
         tip("服务器异常")
      }
     })
   }